package com.sajus.web.billing.ejb.data.model;

import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.sajus.billing.client.dto.UsageItemLineDTO;

@Entity
@Table(name = "billitem")
@NamedQueries({
	@NamedQuery(name = "BillItem.findAll", query = "SELECT b FROM BillItem b"),
	@NamedQuery(name = "BillItem.findCurrentIndex", query ="SELECT r FROM BillItem r WHERE r.id= ( SELECT max(d.id) FROM BillItem d )" )
	})
public class BillItem extends PersistentObject{

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name = "id")
	private Integer id;
	
	private int type;
	private int lineNumber;
	private double amount;
	private String description;
	private String serviceReference;
	private String Jurisdiction;
	private boolean isProrated;
	private double proratedUsage;
	private int discountType;
	private double discountRate;
	private int taxType;
	private double taxRate;
	
	@ManyToOne(cascade=CascadeType.ALL)
	@JoinColumn(name="bill")
	private Bill bill;

	@OneToMany( mappedBy="billitem", cascade=CascadeType.ALL )
	private List<UsageItemLine> usageLineItems;
	
	@Override
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public int getLineNumber() {
		return lineNumber;
	}

	public void setLineNumber(int lineNumber) {
		this.lineNumber = lineNumber;
	}

	public double getAmount() {
		return amount;
	}

	public void setAmount(double amount) {
		this.amount = amount;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getServiceReference() {
		return serviceReference;
	}

	public void setServiceReference(String serviceReference) {
		this.serviceReference = serviceReference;
	}

	public String getJurisdiction() {
		return Jurisdiction;
	}

	public void setJurisdiction(String jurisdiction) {
		Jurisdiction = jurisdiction;
	}

	public boolean isProrated() {
		return isProrated;
	}

	public void setProrated(boolean isProrated) {
		this.isProrated = isProrated;
	}

	public double getProratedUsage() {
		return proratedUsage;
	}

	public void setProratedUsage(double proratedUsage) {
		this.proratedUsage = proratedUsage;
	}

	public int getDiscountType() {
		return discountType;
	}

	public void setDiscountType(int discountType) {
		this.discountType = discountType;
	}

	public double getDiscountRate() {
		return discountRate;
	}

	public void setDiscountRate(double discountRate) {
		this.discountRate = discountRate;
	}

	public int getTaxType() {
		return taxType;
	}

	public void setTaxType(int taxType) {
		this.taxType = taxType;
	}

	public double getTaxRate() {
		return taxRate;
	}

	public void setTaxRate(double taxRate) {
		this.taxRate = taxRate;
	}

	public Bill getBill() {
		return bill;
	}

	public void setBill(Bill bill) {
		this.bill = bill;
	}

	public List<UsageItemLine> getUsageLineItems() {
		return usageLineItems;
	}

	public void setUsageLineItems(List<UsageItemLine> usageLineItems) {
		this.usageLineItems = usageLineItems;
	}
	
}
